<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>When to use transforms | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'transform-usage.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/transform-usage.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/transform-usage.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/transform-usage.html" rel="nofollow" target="_blank">../en/transform-usage.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="data-rollup-transform.html">Roll up or transform your data</a></span>
»
<span class="breadcrumb-link"><a href="transforms.html">Transforming data</a></span>
»
<span class="breadcrumb-node">When to use transforms</span>
</div>
<div class="navheader">
<span class="prev">
<a href="transform-setup.html">« Set up transforms</a>
</span>
<span class="next">
<a href="transform-checkpoints.html">How transform checkpoints work »</a>
</span>
</div>
<div class="section xpack">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="transform-usage"></a>When to use transforms<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/transform/usage.asciidoc">edit</a><a class="xpack_tag" href="https://www.elastic.co/subscriptions"></a>
</h2>
</div></div></div>
<p>Elasticsearch aggregations are a powerful and flexible feature that enable you to
summarize and retrieve complex insights about your data. You can summarize
complex things like the number of web requests per day on a busy website, broken
down by geography and browser type. If you use the same data set to try to
calculate something as simple as a single number for the average duration of
visitor web sessions, however, you can quickly run out of memory.</p>
<p>Why does this occur? A web session duration is an example of a behavioral
attribute not held on any one log record; it has to be derived by finding the
first and last records for each session in our weblogs. This derivation requires
some complex query expressions and a lot of memory to connect all the data
points. If you have an ongoing background process that fuses related events from
one index into entity-centric summaries in another index, you get a more useful,
joined-up picture. This new index is sometimes referred to as a <em>data frame</em>.</p>
<p>You might want to consider using transforms instead of aggregations when:</p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<p>You need a complete <em>feature index</em> rather than a top-N set of items.</p>
<p>In machine learning, you often need a complete set of behavioral features rather just the
top-N. For example, if you are predicting customer churn, you might look at
features such as the number of website visits in the last week, the total number
of sales, or the number of emails sent. The Elastic Stack machine learning features create models
based on this multi-dimensional feature space, so they benefit from the full
feature indices that are created by transforms.</p>
<p>This scenario also applies when you are trying to search across the results of
an aggregation or multiple aggregations. Aggregation results can be ordered or
filtered, but there are
<a href="search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation-order" class="ulink" target="_top">limitations to ordering</a>
and
<a href="search-aggregations-pipeline-bucket-selector-aggregation.html" class="ulink" target="_top">filtering by bucket selector</a>
is constrained by the maximum number of buckets returned. If you want to search
all aggregation results, you need to create the complete data frame. If you
need to sort or filter the aggregation results by multiple fields, transforms
are particularly useful.</p>
</li>
<li class="listitem">
<p>You need to sort aggregation results by a pipeline aggregation.</p>
<p><a href="search-aggregations-pipeline.html" class="ulink" target="_top">Pipeline aggregations</a> cannot be used
for sorting. Technically, this is because pipeline aggregations are run during
the reduce phase after all other aggregations have already completed. If you
create a transform, you can effectively perform multiple passes over the data.</p>
</li>
<li class="listitem">
<p>You want to create summary tables to optimize queries.</p>
<p>For example, if you
have a high level dashboard that is accessed by a large number of users and it
uses a complex aggregation over a large dataset, it may be more efficient to
create a transform to cache results. Thus, each user doesn’t need to run the
aggregation query.</p>
</li>
</ul>
</div>
</div>
<div class="navfooter">
<span class="prev">
<a href="transform-setup.html">« Set up transforms</a>
</span>
<span class="next">
<a href="transform-checkpoints.html">How transform checkpoints work »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>